import {
  aspectFillaspectFill,
  loginWithCode,
  getProductList,
  indeAlert,
  bannerList,
  activityList,
  activityDetail,
  collectGoods,
  getBeShared,
  channelList,
  categoryType,
  addFormId,
  getCatalog,
  brandLike,
  onShared
} from "../../../api.js"
var app = getApp().globalData
Page({
  data: {
    tabLis: [{
      id: 0,
      text: '推荐'
    }, {
      id: 1,
      text: '箱包'
    }, {
      id: 2,
      text: '腕表'
    }, {
      id: 3,
      text: '首饰'
    }, {
      id: 4,
      text: '配饰'
    }],
    form:false,
    tabType: 0,
    options_data: [],
    couponPopup_nav: false,
    alert_img: '',
    bannerCon_img: '',
    productList: [],
    none: true,
    scrollTop: 0,
    scrTop: false,
    bottomBull: true,
    channel_list: [{
      id: '',
      pic: ''
    }, {
      id: '',
      pic: ''
    }, {
      id: '',
      pic: ''
    }, {
      id: '',
      pic: ''
    }, {
      id: '',
      pic: ''
    }, {
      id: '',
      pic: ''
    }],
    sort_nav_type: false,
    sort_nav_one: -1,
    sort_nav_four: -1,
    icon_img: ['https://document.growthupup.com/arrowbot.png', 'https://document.growthupup.com/arrowtop.png'],
    sort:{
      mo:true,
      sort:false,
      type:false,
      sort_icona:false,
      sort_iconb:false,
      a:true,
      b:true
    },
    sort_one_list: [{
      id: 2,
      name: '最新上架'
    }, {
      id: 3,
      name: '加购次数'
    }, {
      id: 4,
      name: '收藏次数',
    }, {
      id: 5,
      name: '分享次数',
    }, {
      id: 6,
      name: '价格升序',
    }, {
      id: 7,
      name: '价格降序',
    }],
    two_classify: [],
    viewHeight: '',
    // 筛选列表
    //品牌列表
    brandApilist: [],
    brandApilist_sou: [],
    // 品牌
    brand: [{
      id: 73,
      title: 'Louis Vuitton',
      type: false
    }, {
      id: 75,
      title: 'Chanel',
      type: false
    }, {
      id: 76,
      title: 'Gucci',
      type: false
    }, {
      id: 72,
      title: 'Hermès',
      type: false
    }],
    // 活动
    activity: [{
      id: 1,
      title: '有活动',
      type: false
    }, {
      id: 2,
      title: '无活动',
      type: false
    }, {
      id: 0,
      title: '全部',
      type: false
    }],
    // 成色
    condition: [{
      id: 7,
      title: '全新',
      type: false
    }, {
      id: 1,
      title: '9.9新',
      type: false
    }, {
      id: 2,
      title: '9.8新',
      type: false
    }, {
      id: 3,
      title: '9.5新',
      type: false
    }, {
      id: 4,
      title: '9.0新',
      type: false
    }, {
      id: 5,
      title: '8.5新',
      type: false
    }, {
      id: 6,
      title: '8.0新',
      type: false
    }],
    // 性别
    gender: [{
      id: 1,
      title: '女士',
      type: false
    }, {
      id: 2,
      title: '男士',
      type: false
    }, {
      id: 3,
      title: '男女通用',
      type: false
    }],
    // 服务
    service: [{
      id: 1,
      title: '专业鉴定',
      type: false
    }, {
      id: 2,
      title: '非质量问题不退换',
      type: false
    }, {
      id: 3,
      title: '售后保障',
      type: false
    }, {
      id: 4,
      title: '会员免邮',
      type: false
    }, {
      id: 5,
      title: '假一赔十',
      type: false
    }, {
      id: 6,
      title: '支持7天内退换',
      type: false
    }, {
      id: 7,
      title: '不支持7天内退换',
      type: false
    }],
    // 包装配件
    parts: [{
      title: '肩带',
      type: false
    }, {
      title: '钥匙',
      type: false
    }, {
      title: '锁',
      type: false
    }, {
      title: '盒子',
      type: false
    }, {
      title: '防尘袋',
      type: false
    }, {
      title: '身份卡',
      type: false
    }, {
      title: '发票',
      type: false
    }, {
      title: '说明书',
      type: false
    }, {
      title: '保卡',
      type: false
    }, {
      title: '国检证书',
      type: false
    }, {
      title: '纸卡',
      type: false
    }, {
      title: '防尘布',
      type: false
    }, {
      title: '纸片',
      type: false
    }, {
      title: '质保卡',
      type: false
    }, {
      title: '内袋',
      type: false
    }, {
      title: '吊牌',
      type: false
    }, {
      title: '表节',
      type: false
    }, {
      title: '配钉',
      type: false
    }, {
      title: '配皮',
      type: false
    }, {
      title: '手提袋',
      type: false
    }, {
      title: '刷卡单',
      type: false
    }, {
      title: '小票',
      type: false
    }, {
      title: '挂件',
      type: false
    }, {
      title: '螺丝刀',
      type: false
    }, {
      title: '手柄',
      type: false
    }, {
      title: '替换袋',
      type: false
    }, {
      title: '皮绳',
      type: false
    }, {
      title: '皮条',
      type: false
    }, {
      title: '羊毛毡',
      type: false
    }, {
      title: '丝带',
      type: false
    }, {
      title: '镜子',
      type: false
    }, {
      title: '扣子',
      type: false
    }, {
      title: '雨衣',
      type: false
    }],
    parts_type: false,
    // 防水性
    waterproperty: [{
      title: '生活防水',
      type: false
    }, {
      title: '30米',
      type: false
    }, {
      title: '50米',
      type: false
    }, {
      title: '300米',
      type: false
    }, {
      title: '其他',
      type: false
    }],
    // 产地
    placeOrigin: [{
      title: '瑞士',
      type: false
    }, {
      title: '日韩',
      type: false
    }, {
      title: '欧美',
      type: false
    }, {
      title: '其他',
      type: false
    }],
    // 颜色
    colorList: [{
      title: '红色',
      type: false
    }, {
      title: '橙色',
      type: false
    }, {
      title: '黄色',
      type: false
    }, {
      title: '绿色',
      type: false
    }, {
      title: '青色',
      type: false
    }, {
      title: '蓝色',
      type: false
    }, {
      title: '紫色',
      type: false
    }, {
      title: '黑色',
      type: false
    }, {
      title: '白色',
      type: false
    }, {
      title: '全部',
      type: false
    }],
    //机芯
    movement: [{
        title: '石英',
        type: false
      },
      {
        title: '自动机械',
        type: false
      }, {
        title: '手动机械',
        type: false
      }
    ],
    screen_form: {
      activity_price: 0,
      star_price: '',
      end_price: '',
      product_condition: [],
      group_people: [],
      service_name: [],
      package_name: [],
      color: [],
      mechanism: [],
      waterproof: [],
      producer: [],
      brand_id: []
    },
    brand_sousou: false,
    screen_alert_lis: false,
    screen_alert_type: true,
    bottom_load_text:'暂无更多数据',
    bottom_load_type:true,
    topbot:3000
  },
  onLoad: function(options) {
    this.setData({
      options_data: options
    })
    if (options.source && options.parent_id){
      beShared({
        token: app.Store.token,
        source: options.source,
        parent_id: options.user_id
      }).then(res => {
        console.log(res)
      })
    }
    
    this.checkUserInfo()
    categoryType().then(res => {
      this.setData({
        two_classify: res.data.data
      })
      console.log(this.data.two_classify)
    })
    var that = this
    // var query = wx.createSelectorQuery();
    // query.select('#scrollHeight').boundingClientRect()
    // query.exec(function(res) {
    //   that.setData({
    //     viewHeight: res[0].height
    //   })
    // })
    getCatalog(app.businessId).then(res => {
      console.log(res)
      that.setData({
        brandApilist: res.data.data[0].children
      })
    })
    channelList(app.businessId).then(res => {
      if (res.data.code == 666) {
        var list = res.data.data
        for (var i = 0; i < list.length; i++) {
          that.data.channel_list[list[i].odinal - 1].id = list[i].id
          that.data.channel_list[list[i].odinal - 1].pic = list[i].picture_url
          if (i == list.length - 1) {
            that.setData({
              channel_list: that.data.channel_list,
            })
          }
        }
      } else {
        wx.showToast({
          title: res.data.msg,
          icon: "none"
        })
      }
    })
    bannerList(app.businessId).then(res => {
      if (res.data.code == 666) {
        if (res.data.data[0]) {
          that.setData({
            bannerCon: res.data.data[0],
            none: false,
          })
        } else {
          that.setData({
            bannerCon_img: 'https://document.growthupup.com/banner_default.png',
          })
        }
      } else if (res.data.code == 111111) {
        that.checkUserInfo()
      }
    })
    activityList(app.businessId).then(res => {
      var that = this
      if (res.data.code == 666) {
        this.setData({
          activityList: res.data.data,
        })
      } else if (res.data.code == 111111) {
        that.checkUserInfo()
      }
    })
  },
  onReady: function() {

  },
  onShow: function() {
    getApp().startpage(new Date().getTime())
  },
  onHide: function() {
    getApp().endpage(new Date().getTime())
  },
  topTab: function(e) {
    this.setData({
        // 初始化
      bottom_load_text: '暂无更多数据',
      bottom_load_type: true
    })
    var id = e.currentTarget.dataset.id
    let token = app.Store.token;
    let options = id == 0 ? '' : id
    var that = this
    if (id == that.data.tabType) return
    that.reset()
    that.setData({
      tabType: id,
      scrollTop: 0
    })
    if (id == 0) {
      that.setData({
        sort_nav_type: false
      })
    }
    getProductList(app.businessId, {
      category_id: options
    }, token).then(res => {
      this.setData({
        bottom_load_text: '正在加载',
        bottom_load_type: false
      })
      if (res.data.code === 666) {
        that.setData({
          productList: res.data.data,
          'sort_navs.one': false,
          'sort_navs.two': true,
          sort_nav_one: -1,
          'sort_navs.three': false,
          'sort_navs.four': false,
          sort_nav_four: -1,
            bottom_load_text: '暂无更多数据',
            bottom_load_type: true
        })
        wx.hideLoading();
      } else if (res.data.code == 111111) {
        that.checkUserInfo()
      } else {
        wx.showToast({
          title: res.data.msg,
          icon: "none"
        })
      }
    })
  },
  // 检查用户信息授权
  checkUserInfo() {
    const xp = this;
    wx.getSetting({
      success: function(res) {
        console.log(res)
        if (!res.authSetting['scope.userInfo']) {
          wx.navigateTo({
            url: '/pages/public/shouquan/shouquan',
          })
        } else {
          wx.getUserInfo({
            success(res) {
              xp.loginWithCode(res.userInfo)
            }
          })
        }
      }
    })
  },
  //登陆
  loginWithCode(userInfo) {
    const xp = this
    wx.login({
      success({
        code
      }) {
        loginWithCode({
          ...userInfo,
          code,
          business_id: app.businessId
        }).then(res => {
          if (res.data.code === 666) {
            app.Store = res.data.data
            xp.options_data_er()
            var token = res.data.data.token;
            var business_id = app.businessId
            indeAlert(
              token,
              business_id
            ).then(res => {
              if (res.data.code == 666) {
                if (res.data.data.receive == 2) {
                  xp.setData({
                    alert_img: res.data.data.ticket,
                    couponPopup_nav: true
                  })
                }
              }
            })
          }
          xp.initPage()
        })
      }
    })
  },
  // 二维码追踪
  options_data_er() {
    var that = this
    if (that.data.options_data.user_id) {
      console.log(that.data.options_data)
      var id = that.data.options_data.user_id
      // var source = that.data.options_data.search(source) ? that.data.options_data.source:""

      getBeShared(app.Store.token, that.data.options_data.user_id).then(res => {})
    } else if (that.data.options_data.name) {
      getBeShared(app.Store.token, '', '', that.data.options_data.name).then(res => {})
    }
  },
  // 优惠券弹窗
  couponPopup: function() {
    this.setData({
      couponPopup_nav: false
    })
    wx.navigateTo({
      url: '/pages/myList/coupon/coupon?total=0',
    })
  },
  close: function() {
    this.setData({
      couponPopup_nav: false
    })
  },
  // 页面初始化
  initPage() {
    let token = getApp().globalData.Store.token;
    var that = this

    getProductList(app.businessId, '', token).then(res => {
      if (res.data.code === 666) {
        that.setData({
          productList: res.data.data
        })
        console.log(this.data.productList)
        wx.hideLoading();
      } else if (res.data.code == 111111) {
        that.checkUserInfo()
      } else {
        wx.showToast({
          title: res.data.msg,
          icon: "none"
        })
      }
    })
  },
  //收藏
  collect(e) {
    let product_id = String(e.currentTarget.dataset.id);
    let token = getApp().globalData.Store.token;
    let index = e.currentTarget.dataset.ind;
    collectGoods({
      product_id,
      token
    }).then(res => {
      if (res.data.code == 666) {
        let isCollect = 'productList.data[' + index + '].user_wishlist'
        this.setData({
          [isCollect]: this.data.productList.data[index].user_wishlist == 1 ? 0 : 1
        })
        if (this.data.productList.data[index].user_wishlist == 0) {
          wx.showToast({
            title: '已取消收藏',
            icon: 'none',
          })
        } else if (this.data.productList.data[index].user_wishlist == 1) {
          wx.showToast({
            title: '已成功收藏',
            icon: 'none',
          })
        }
      } // else if (res.data.code == 111111) {
      //   that.checkUserInfo()
      // }
    })
  },
  bindscroll(e) {
    var sctop = e.detail.scrollTop
    var that = this
    if (sctop > 1500) {
      that.setData({
        scrTop: true
      })
    } else {
      that.setData({
        scrTop: false
      })
    }
    var query = wx.createSelectorQuery()
    query.select('#sort_nav').boundingClientRect()
    query.exec(function(res) {
      if (res[0].top < 77) {
        that.setData({
          sort_nav_type: true
        })
      } else {
        that.setData({
          sort_nav_type: false
        })
      }
    })
  },
  scrolltoTop() {
    this.setData({
      scrollTop: 0
    })
  },
  productBottom() {
    let total = this.data.productList.last_page
    let current = this.data.productList.current_page
    let business = app.Store.business.id
    let token = app.Store.token;
    var that = this
    let options = this.data.tabType == 0 ? '' : this.data.tabType
    let order_by = this.data.sort_nav_one == -1 ? '' : this.data.sort_one_list[this.data.sort_nav_one].id
    // wx.showToast({
    //   title: '正在加载',
    //   icon: "loading"
    // })
    if (total === current) {
      that.setData({
        bottom_load_text:'暂无更多商品',
        bottom_load_type:true
      })
      return
    }
    if (that.data.bottomBull) {
      that.setData({
        bottomBull: false
      })
    } else {
      console.log('1a1')
      return
    }
    getProductList(business, {
      category_id: options,
      page: ++current,
      type_id: this.data.tabid
      
    }, token, order_by, { ...that.data.screen_form
    }).then(res => {
      this.setData({
        bottom_load_text: '正在加载',
        bottom_load_type: false
      })
      if (res.data.code === 666) {
        let productList = this.data.productList
        productList.data = productList.data.concat(res.data.data.data)
        productList.current_page = current
        that.setData({
          productList: productList,
          bottomBull: true,
        })
        if (res.data.data.data.length == 0) {
          this.setData({
            bottom_load_text: "暂无更多商品",
            bottom_load_type: true
          })
        }
      } else if (res.data.code == 111111) {
        that.checkUserInfo()
      } else {
        wx.showToast({
          title: res.data.msg,
          icon: "none"
        })
      }
    })
  },
  //活动
  skipActiveDetails(e) {
    let token = getApp().globalData.Store.token;
    let id = e.currentTarget.dataset.id;
    var that = this
    activityDetail(token, id).then(res => {
      if (res.data.code == 666) {
        if (res.data.data[0].product_list.length > 0) {
          wx.navigateTo({
            url: '/pages/homepage/activeDetails/activeDetails?id=' + e.currentTarget.dataset.id,
          })
        }
      } else if (res.data.code == 111111) {
        wx.showToast({
          title: '网络错误，请稍候重试',
          icon: "none"
        })
        that.checkUserInfo()
      }
    })
  },
  onShareAppMessage(res) {
    return {
      title: "芮享一种轻奢生活的新方式",
      imageUrl: "https://document.growthupup.com/shareday.png?t=" + new Date().getTime()
    }
  },
  result(){
    that.setData({
      "sort_navs.two": false,
      "sort_navs.fours": false
    })
  },
  sort_one_btn() {
    var that = this
    that.setData({
      'sort.mo': false,
      "sort.sort":!this.data.sort.sort,
      "sort.type":false,
      "sort.sort_icona": !this.data.sort.sort_icona,
      "sort.sort_iconb": false,
      "sort.a":!this.data.sort.a,
      "sort.b":true,
      bottom_load_text: '暂无更多数据',
      bottom_load_type: true,
    })
  },
  sort_onelis_btn(e) {
    var index = e.currentTarget.dataset.ind
    var that = this
    let options = this.data.tabType == 0 ? '' : this.data.tabType
    let type_id = that.data.tabType == 0 || that.data.sort_nav_four == -1 ? '' : that.data.two_classify[that.data.tabType - 1].children[that.data.sort_nav_four].id
    console.log(type_id)
    that.setData({
      sort_nav_one: index,
      "sort.mo":false,
      "sort.sort":true,
      "sort.type":false,
      "sort.sort_icona":true,
      "sort.sort_iconb":false,
      "sort.a":true,
      "sort.b":true,
      bottom_load_text: '暂无更多数据',
      bottom_load_type: true,
    })
    getProductList(app.businessId, {
      category_id: options,
      type_id: type_id
    }, app.Store.token, that.data.sort_one_list[index].id, { ...that.data.screen_form
    }).then(res => {
      this.setData({
        bottom_load_text: '正在加载',
        bottom_load_type: false
      })
      if (res.data.code == 666) {
        that.setData({
          productList: res.data.data
        })
      }
    })
  },
  sort_fourlis_btn(e) {
    var index = e.currentTarget.dataset.ind
    let options = this.data.tabType == 0 ? '' : this.data.tabType
    var that = this
    let type_id = that.data.tabType == 0 ? '' : that.data.two_classify[that.data.tabType - 1].children[index].id
    console.log(type_id)
    let order_by = that.data.sort_nav_one == -1 ? '' : that.data.sort_one_list[that.data.sort_nav_one].id
    that.setData({
      sort_nav_four: index,
      tabid: type_id,
      "sort.mo":false,
      "sort.sort":false,
      "sort.type":true,
      "sort.sort_icona":false,
      "sort.sort_iconb":true,
      "sort.a":true,
      "sort.b":true,
      bottom_load_text: '暂无更多数据',
      bottom_load_type: true
    })
    getProductList(app.businessId, {
      category_id: options,
      type_id: type_id
    }, app.Store.token, order_by, { ...that.data.screen_form
    }).then(res => {
      if (res.data.code == 666) {
        that.setData({
          productList: res.data.data
        })
        if (this.data.productList.data==null) {
          this.setData({
            bottom_load_text: "暂无更多商品",
            bottom_load_type: true
          })
        }
      }
    })
  },
  sort_mo() {
    var that = this
    let options = this.data.tabType == 0 ? '' : this.data.tabType
    that.setData({
      sort_one_list: that.data.sort_one_list,
      "sort.mo":true,
      "sort.sort":false,
      "sort.type":false,
      "sort.sort_icona":false,
      "sort.sort_iconb":false,
      "sort.a":true,
      "sort.b":true,
      sort_nav_one: -1,
      sort_nav_four: -1,
      bottom_load_text: '暂无更多数据',
      bottom_load_type: true,
    })
    getProductList(app.businessId, {
      category_id: options,
      order_by: 1
    }, app.Store.token).then(res => {
      if (res.data.code == 666) {
        that.setData({
          productList: res.data.data
        })
      }
    })
  },
  sort_three_btn() {
    var that = this
    // that.setData({
    //   'sort_navs.three': !that.data.sort_navs.three
    // })
  },
  sort_four_btn() {
    var that = this
    that.setData({
      "sort.mo": false,
      "sort.sort": false,
      "sort.sort_icona": false,
      "sort.type": !this.data.sort.type,
      "sort.sort_iconb": !this.data.sort.sort_iconb,
      "sort.a":true,
      "sort.b":!this.data.sort.b,
      bottom_load_text: '暂无更多数据',
      bottom_load_type: true,
    })
    console.log(this.data.sort.sort_icona)
    console.log(this.data.sort.sort)
  },
  form_share(e) {
    var id = e.detail.formId
    addFormId(app.Store.token, id, 1).then(res => {})
    wx.navigateTo({
      url: '/pages/activity/list/list'
    })
  },
  //筛选弹窗
  close_screen() {
    this.setData({
      screen_alert_type: true
    })
  },
  saixuan() {
    this.setData({
      screen_alert_type: false,
      bottom_load_text: '暂无更多数据',
      bottom_load_type: true,
      // "sort.mo": false,
      // "sort.sort": false,
      // "sort.type": false,
      // "sort.sort_icona": false,
      // "sort.sort_iconb": false,
      // "sort.a": true,
      // "sort.b": true,
    })
  },
  screen_list() {
    console.log(2)
  },
  //包装配件全部按钮
  parts_btn_all() {
    var that = this
    that.setData({
      parts_type: !that.data.parts_type
    })
  },
  //活动按钮
  activity_btn(e) {
    var index = e.currentTarget.dataset.index
    var that = this
    that.data.screen_form.activity_price = index
    that.setData({
      screen_form: that.data.screen_form
    })
  },
  //成色按钮
  condition_btn(e) {
    var index = e.currentTarget.dataset.index
    var that = this
    that.data.condition[index].type = !that.data.condition[index].type
    that.setData({
      condition: that.data.condition
    })
  },
  //性别按钮
  gender_btn(e) {
    var index = e.currentTarget.dataset.index
    var that = this
    that.data.gender[index].type = !that.data.gender[index].type
    that.setData({
      gender: that.data.gender
    })
  },
  // 颜色按钮
  colorList_btn(e) {
    var index = e.currentTarget.dataset.index
    var that = this
    for (let i in that.data.colorList) {
      that.data.colorList[i].type = false
    }
    that.data.colorList[index].type = !that.data.colorList[index].type
    that.setData({
      colorList: that.data.colorList
    })
  },
  //机芯
  movement_btn(e) {
    var index = e.currentTarget.dataset.index
    var that = this
    that.data.movement[index].type = !that.data.movement[index].type
    that.setData({
      movement: that.data.movement
    })
  },
  //防水性
  waterproperty_btn(e) {
    var index = e.currentTarget.dataset.index
    var that = this
    that.data.waterproperty[index].type = !that.data.waterproperty[index].type
    that.setData({
      waterproperty: that.data.waterproperty
    })
  },
  //产地按钮
  placeOrigin_btn(e) {
    var index = e.currentTarget.dataset.index
    var that = this
    that.data.placeOrigin[index].type = !that.data.placeOrigin[index].type
    that.setData({
      placeOrigin: that.data.placeOrigin
    })
  },
  //服务按钮
  service_btn(e) {
    var index = e.currentTarget.dataset.index
    var that = this
    that.data.service[index].type = !that.data.service[index].type
    that.setData({
      service: that.data.service
    })
  },
  //配件按钮
  parts_btn(e) {
    var index = e.currentTarget.dataset.index
    var that = this
    that.data.parts[index].type = !that.data.parts[index].type
    that.setData({
      parts: that.data.parts
    })
  },
  //品牌筛选
  brand_btn(e) {
    var index = e.currentTarget.dataset.index
    var that = this
    that.data.brand[index].type = !that.data.brand[index].type
    that.setData({
      brand: that.data.brand
    })
  },
  miniPrice(e) {
    this.setData({
      'screen_form.star_price': e.detail.value
    })
  },
  maxiPrice(e) {
    this.setData({
      'screen_form.end_price': e.detail.value
    })
  },
  //品牌模糊搜索
  top_bindinput(e) {
    var text = e.detail.value
    var that = this
    if (text.length == 0) {
      that.setData({
        brand_sousou: false
      })
    } else {
      brandLike(
        text
      ).then(res => {
        if (res.data.code == 666) {
          that.setData({
            brand_sousou: true,
            brandApilist_sou: res.data.data,
          })
        }
        console.log(res)
      })
    }
  },
  brand_all() {
    this.setData({
      screen_alert_lis: true
    })
  },
  close_brand_all() {
    this.setData({
      screen_alert_lis: false
    })
  },
  brandApilist_btn(e) {
    var index = e.currentTarget.dataset.index
    var that = this
    var lis = {}
    for (let i in that.data.brand) {
      console.log(that.data.brand[i])
      if (that.data.brand[i].id == that.data.brandApilist[index].id) {
        that.data.brand[i].type = true
        that.setData({
          screen_alert_lis: false,
          brand: that.data.brand,
          brand_sousou: false
        })
        that.data.brand[i].type = true
        return
      } else {
        lis.id = that.data.brandApilist[index].id
        lis.title = that.data.brandApilist[index].title
        lis.type = true
      }
    }
    that.data.brand.push(lis)
    that.setData({
      screen_alert_lis: false,
      brand: that.data.brand,
      brand_sousou: false
    })
  },
  brandApilist_sou_btn(e) {
    var index = e.currentTarget.dataset.index
    var that = this
    var lis = {}
    for (let i in that.data.brand) {
      console.log(that.data.brand[i])
      if (that.data.brand[i].id == that.data.brandApilist_sou[index].id) {
        that.data.brand[i].type = true
        that.setData({
          screen_alert_lis: false,
          brand: that.data.brand,
          brand_sousou: false
        })
        return
      } else {
        console.log(that.data.brandApilist_sou[index].title)
        lis.id = that.data.brandApilist_sou[index].id
        lis.title = that.data.brandApilist_sou[index].title_en
        lis.type = true
      }
    }
    that.data.brand.push(lis)
    that.setData({
      screen_alert_lis: false,
      brand: that.data.brand,
      brand_sousou: false
    })
  },
  //重置
  reset() {
    var that = this
    var lis = that.data
    for (let i in lis.condition) {
      lis.condition[i].type = false
    }
    for (let i in lis.gender) {
      lis.gender[i].type = false
    }
    for (let i in lis.colorList) {
      lis.colorList[i].type = false
    }
    for (let i in lis.waterproperty) {
      lis.waterproperty[i].type = false
    }
    for (let i in lis.placeOrigin) {
      lis.placeOrigin[i].type = false
    }
    for (let i in lis.service) {
      lis.service[i].type = false
    }
    for (let i in lis.parts) {
      lis.parts[i].type = false
    }
    for (let i in lis.brand) {
      lis.brand[i].type = false
    }
    for (let i in lis.movement) {
      lis.movement[i].type = false
    }
    that.setData({
      condition: lis.condition,
      gender: lis.gender,
      colorList: lis.colorList,
      waterproperty: lis.waterproperty,
      placeOrigin: lis.placeOrigin,
      service: lis.service,
      parts: lis.parts,
      brand: lis.brand,
      movement: lis.movement,
      'screen_form.activity_price': 0,
      'screen_form.end_price': '',
      'screen_form.star_price': ''
    })
  },
  //确认查询
  form_confirm() {
    var that = this
    var lis = that.data
    var ban_id = []
    for (let i in lis.brand) {
      if (lis.brand[i].type) {
        ban_id.push(lis.brand[i].id)
      }
    }
    lis.screen_form.brand_id = ban_id
    var condition_id = []
    for (let i in lis.condition) {
      if (lis.condition[i].type) {
        condition_id.push(lis.condition[i].id)
      }
    }
    lis.screen_form.product_condition = condition_id
    var gender_id = []
    for (let i in lis.gender) {
      if (lis.gender[i].type) {
        gender_id.push(lis.gender[i].title)
      }
    }
    lis.screen_form.group_people = gender_id
    var colorList_id = ''
    for (let i in lis.colorList) {
      if (lis.colorList[i].type && i != 9) {
        colorList_id = lis.colorList[i].title.substr(0, lis.colorList[i].title.length-1)
      }
    }
    lis.screen_form.color = colorList_id
    var movement_id = []
    for (let i in lis.movement) {
      if (lis.movement[i].type) {
        movement_id.push(lis.movement[i].title)
      }
    }
    lis.screen_form.mechanism = movement_id
    var waterproperty_id = []
    for (let i in lis.waterproperty) {
      if (lis.waterproperty[i].type) {
        waterproperty_id.push(lis.waterproperty[i].title)
      }
    }
    lis.screen_form.waterproof = waterproperty_id
    var placeOrigin_id = []
    for (let i in lis.placeOrigin) {
      if (lis.placeOrigin[i].type) {
        placeOrigin_id.push(lis.placeOrigin[i].title)
      }
    }
    lis.screen_form.producer = placeOrigin_id
    var service_id = []
    for (let i in lis.service) {
      if (lis.service[i].type) {
        service_id.push(lis.service[i].title)
      }
    }
    lis.screen_form.service_name = service_id
    var parts_id = []
    for (let i in lis.parts) {
      if (lis.parts[i].type) {
        parts_id.push(lis.parts[i].title)
      }
    }
    lis.screen_form.package_name = parts_id
    let options = this.data.tabType == 0 ? '' : this.data.tabType
    let type_id = that.data.tabType == 0 || that.data.sort_nav_four == -1 ? '' : that.data.two_classify[that.data.tabType - 1].children[that.data.sort_nav_four].id
    let order_by = that.data.sort_nav_one == -1 ? '' : that.data.sort_one_list[that.data.sort_nav_one].id
    getProductList(app.businessId, {
      category_id: options,
      type_id: type_id
    }, app.Store.token, order_by, { ...lis.screen_form
    }).then(res => {
      if (res.data.code == 666) {
        console.log(res.data.data.data)
        if (res.data.data.data==null){
          this.setData({
            // 不敢了
            bottom_load_text: '暂无更多数据',
            bottom_load_type: true,
          })
        }
        that.setData({
          productList: res.data.data,
          screen_alert_type: true
        })
        
      }
    })
    console.log(lis.screen_form)
  },
  das(e){
    console.log('22')
  }
})